
import win32com.client as win32

def get_folder_by_type(folder_type):
    outlook = win32.Dispatch('Outlook.Application')
    namespace = outlook.GetNamespace("MAPI")
    folder = namespace.GetDefaultFolder(folder_type)

    return folder

# 获取发件箱对象
sent_items_folder = get_folder_by_type(5)
print(sent_items_folder)

# 获取日历对象
calendar_folder = get_folder_by_type(9)
print(calendar_folder)

# 获取任务对象
tasks_folder = get_folder_by_type(25)
print(tasks_folder)